<?php
	session_start();
	header("Content-type: text/javascript");
	$browser = strtolower($_SERVER['HTTP_USER_AGENT']);
	$browser = (strstr($browser, 'MSIE')) ? 'ie' : 'ff';
?>	
	
	function go(url)
	{
		document.location.href = url;
	}
	
	function Get_HTML(url, methode)
	{
		methode = methode.toUpperCase();
		if (window.XMLHttpRequest)
	        var objXHR = new XMLHttpRequest();
		else
		{
	        if (window.ActiveXObject)
	            var objXHR = new ActiveXObject("Microsoft.XMLHTTP");
			else
	            return false;
	    }

	    objXHR.open(methode, url, false);
		if (methode == 'POST')
			objXHR.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	    objXHR.send(null);

	    if (objXHR.readyState == 4)
	        return objXHR.responseText;
	    else
	        return false;
	}
	
	function track()
	{
		var url = urlsite + 'index.php?track=1&langue_track=' + applng + '&page_track=' + pagetrack;
		Get_HTML(url, 'GET');
	}
	
	function contient(chaine, verif)
	{
		var compte = 0; 
	 
		for (var i = 0; i < chaine.length; i++) 
		{
			if (verif.indexOf(chaine.charAt(i)) > -1) 
				compte++; 
		} 
		return compte; 
	}
	
	
	var keyStr = "ABCDEFGHIJKLMNOP" + "QRSTUVWXYZabcdef" + "ghijklmnopqrstuv" + "wxyz0123456789+/" + "=";

	function encode64(input) 
	{
		input = escape(input);
		var output = "";
		var chr1, chr2, chr3 = "";
		var enc1, enc2, enc3, enc4 = "";
		var i = 0;

		do 
		{
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);

			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;

			if (isNaN(chr2))
				enc3 = enc4 = 64;
			else if (isNaN(chr3))
				enc4 = 64;

			output = output +
			keyStr.charAt(enc1) +
			keyStr.charAt(enc2) +
			keyStr.charAt(enc3) +
			keyStr.charAt(enc4);
			chr1 = chr2 = chr3 = "";
			enc1 = enc2 = enc3 = enc4 = "";
		} 
		while (i < input.length);

		return output;
	}
	
	function pause(sec) 
	{
		var maintenant = new Date();
		var millisecondes = sec * 1000;
		var sortie = maintenant.getTime() + millisecondes;
		
		while (true) 
		{
			maintenant = new Date();
			if (maintenant.getTime() > sortie)
				return;
		}
	}
	
	function getPageScroll()
	{
		var yScroll;

		if (self.pageYOffset) 
			yScroll = self.pageYOffset;
		else if (document.documentElement && document.documentElement.scrollTop)
			yScroll = document.documentElement.scrollTop;
		else if (document.body)
			yScroll = document.body.scrollTop;

		arrayPageScroll = new Array('', yScroll) 
		return arrayPageScroll;
	}

	
	function getPageSize()
	{
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) 
		{	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} 
		else if (document.body.scrollHeight > document.body.offsetHeight)
		{ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} 
		else 
		{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		if (self.innerHeight) 
		{	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} 
		else if (document.documentElement && document.documentElement.clientHeight) 
		{ // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} 
		else if (document.body) 
		{ // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight)
			pageHeight = windowHeight;
		else
			pageHeight = yScroll;

		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth)
			pageWidth = windowWidth;
		else
			pageWidth = xScroll;


		arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight) 
		return arrayPageSize;
	}